// import Cookies from 'js-cookie'
import { getToken, setToken } from '@/utils/auth'

const state = {
  token: getToken()
}
const mutations = {
  SET_TOKEN: (state, token) => {
    state.token = token
  }
}
const actions = {
  login({ commit }, payload) {
    // 用户账号密码
    const { username, password } = payload
    return new Promise((resolve, reject) => {
      const token = `${username} + ${password}`
      commit('SET_TOKEN', token)
      setToken(token)
      resolve(token)
    })
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
